package com.flame.shapeville.component.task1.shape3D;

import javafx.scene.paint.Color;
import javafx.scene.shape.MeshView;
import javafx.scene.shape.TriangleMesh;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User:22954
 * Date:2025-05-12
 * Time:23:10
 */
public class JfTriangularPrism extends JfShape3D {
    public JfTriangularPrism(double size) {
        super(size);
        TriangleMesh mesh = new TriangleMesh();
        float z = (float) size / 3f * 2;
        float height = (float) size;

        float x1 = 0, y1 = height, z1 = 0;
        float x2 = 0, y2 = height, z2 = -z;
        float x3 = (float) size, y3 = height, z3 = -z;
        float x4 = (float) size, y4 = height, z4 = 0;
        float x5 = 0, y5 = 0, z5 = -z / 2f;
        float x6 = (float) size, y6 = 0, z6 = -z / 2f;

        mesh.getPoints().addAll(
                x1, y1, z1,
                x2, y2, z2,
                x3, y3, z3,
                x4, y4, z4,
                x5, y5, z5,
                x6, y6, z6
        );

        mesh.getTexCoords().addAll(0.0f, 0.0f);

        mesh.getFaces().addAll(

                0, 0, 2, 0, 1, 0,
                0, 0, 3, 0, 2, 0,

                0, 0, 1, 0, 4, 0,
                2, 0, 3, 0, 5, 0,

                0, 0, 4, 0, 5, 0,
                0, 0, 5, 0, 3, 0,

                1, 0, 5, 0, 4, 0,
                1, 0, 2, 0, 5, 0
        );
        shape = new MeshView(mesh);
        initBaseParams(Color.CYAN);
        //shape.setRotationAxis(new Point3D(1, 0, 0));
        //shape.setRotate(180);
    }
}
